package com.gobo.statisticsservice.controller;


import com.gobo.commonutils.R;
import com.gobo.statisticsservice.service.StatisticsDailyService;
import com.sun.org.apache.xpath.internal.operations.Bool;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * <p>
 * 网站统计日数据 前端控制器
 * </p>
 *
 * @author gobo-generator
 * @since 2021-09-25
 */
@RestController
@RequestMapping("/statisticsservice/daily")
public class StatisticsDailyController {

    @Autowired
    private StatisticsDailyService statisticsDailyService;

    @GetMapping("/")
    public R ddd(){

        return R.ok();
    }

    @PostMapping("create/{day}")
    public R createStatisticsByDay(@PathVariable String day){
        Boolean isSave =  statisticsDailyService.saveStatisticsByDay(day);
        return isSave?R.ok():R.error();
    }
    @PostMapping("getChartData")
    public R getChartData(@RequestParam(required = false) String typeName,@RequestParam(required = false) String begin,@RequestParam(required = false) String end){

        Map<String,Object> map   = statisticsDailyService.getChartData(typeName,begin,end);

        return R.ok().data(map);
    }


}

